export default {
    namespaced: true,
    state: {
        // 是否显示提示框
        isShowToast: false,
        // 提示内容
        toastMsg: "我是vuex提示内容",
        // 提示类型-图标 (success,danger,warning)
        toastType: 'warning'
    },
    mutations: {
        changeIsShowToast(state, payload) {
            // console.log("修改提示框显示转台", payload);
            state.isShowToast = payload.isShow
            if (payload.isShow) {
                state.toastType = payload.type;
                state.toastMsg = payload.title;
            }
        }
    },
    actions: {
        asyncShowToast(context, payload) {
            context.commit("changeIsShowToast", payload);
            // 自动关闭提示框
            setTimeout(() => {
                context.commit("changeIsShowToast", {
                    isShow: false,
                })
            }, 2000)
        }
    }
}